package com.hzhr.iot.device.convertor;

import com.hzhr.iot.device.convertor.custom.*;
import com.hzhr.iot.core.util.HzhrTypeUtil;
import com.hzhr.iot.core.util.HzhrJsonUtil;
import java.util.Map;
import com.hzhr.iot.device.entity.DeviceMaintenanceCardEntity;
import com.hzhr.iot.device.entity.ext.DeviceMaintenanceCardEntityExt;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import com.hzhr.iot.device.model.regulatorDevice_maintenanceCard.RegulatorDevice_MaintenanceCardModel;
import com.hzhr.iot.device.model.regulatorDevice_maintenanceCard.RegulatorDevice_MaintenanceCardGetModel;
import com.hzhr.iot.device.model.regulatorDevice_maintenanceCard.RegulatorDevice_MaintenanceCardPostModel;
import com.hzhr.iot.device.queryModel.custom.DeviceMaintenanceCardCustomQueryModel;

@Component
public class DeviceMaintenanceCardConvertor {
    @Autowired
    AlarmDataCustomConvertor alarmDataCustomConvertor;
    @Autowired
    CollectDataCustomConvertor collectDataCustomConvertor;
    @Autowired
    CollectDeviceCustomConvertor collectDeviceCustomConvertor;
    @Autowired
    CollectDeviceTypeCustomConvertor collectDeviceTypeCustomConvertor;
    @Autowired
    DeviceInfoCardCustomConvertor deviceInfoCardCustomConvertor;
    @Autowired
    DeviceMaintenanceCardItemCustomConvertor deviceMaintenanceCardItemCustomConvertor;
    @Autowired
    ImplFactoryCustomConvertor implFactoryCustomConvertor;
    @Autowired
    ImplIotDeviceTypeCustomConvertor implIotDeviceTypeCustomConvertor;
    @Autowired
    ImplRecordCustomConvertor implRecordCustomConvertor;
    @Autowired
    IotDeviceCustomConvertor iotDeviceCustomConvertor;
    @Autowired
    IotDeviceTypeCustomConvertor iotDeviceTypeCustomConvertor;
    @Autowired
    OptionsCustomConvertor optionsCustomConvertor;
    @Autowired
    ProdFactoryCustomConvertor prodFactoryCustomConvertor;
    @Autowired
    RegulatorCollectDataCustomConvertor regulatorCollectDataCustomConvertor;
    @Autowired
    UserCompanyCustomConvertor userCompanyCustomConvertor;

    public DeviceMaintenanceCardEntity regulatorDevice_MaintenanceCardModel2entity(RegulatorDevice_MaintenanceCardModel in) {
        //未转换字段: createUserId createTime updateUserId isValid updateTime state 
        if (in == null) return null;
        DeviceMaintenanceCardEntity result = new DeviceMaintenanceCardEntity();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setYear(HzhrTypeUtil.object2string(in.getYear()));
        return result;
    }
    public DeviceMaintenanceCardEntity regulatorDevice_MaintenanceCardModel2entity(RegulatorDevice_MaintenanceCardModel in, DeviceMaintenanceCardEntity ori) {
        //未转换字段: createUserId createTime updateUserId isValid updateTime state 
        if (in == null) return null;
        DeviceMaintenanceCardEntity result = ori;

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setYear(HzhrTypeUtil.object2string(in.getYear()));
        return result;
    }
    public List<DeviceMaintenanceCardEntity> regulatorDevice_MaintenanceCardModelList2entityList(List<RegulatorDevice_MaintenanceCardModel> in) {
        if (in == null) return null;
        List<DeviceMaintenanceCardEntity> result = new ArrayList<>();
        for (RegulatorDevice_MaintenanceCardModel item : in) {
            result.add(regulatorDevice_MaintenanceCardModel2entity(item));
        }
        return result;
    }
    public RegulatorDevice_MaintenanceCardModel entity2regulatorDevice_MaintenanceCardModel(DeviceMaintenanceCardEntity in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_MaintenanceCardModel result = new RegulatorDevice_MaintenanceCardModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setYear(HzhrTypeUtil.string2integer(in.getYear()));
        return result;
    }
    public List<RegulatorDevice_MaintenanceCardModel> entityList2regulatorDevice_MaintenanceCardModelList(List<DeviceMaintenanceCardEntity> in) {
        if (in == null) return null;
        List<RegulatorDevice_MaintenanceCardModel> result = new ArrayList<>();
        for (DeviceMaintenanceCardEntity item : in) {
            result.add(entity2regulatorDevice_MaintenanceCardModel(item));
        }
        return result;
    }
    public RegulatorDevice_MaintenanceCardModel ext2regulatorDevice_MaintenanceCardModel(DeviceMaintenanceCardEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_MaintenanceCardModel result = new RegulatorDevice_MaintenanceCardModel();

        result.setId(HzhrTypeUtil.integer2integer(in.getId()));
        result.setDeviceId(HzhrTypeUtil.integer2integer(in.getDeviceId()));
        result.setYear(HzhrTypeUtil.string2integer(in.getYear()));
        return result;
    }
    public List<RegulatorDevice_MaintenanceCardModel> extList2regulatorDevice_MaintenanceCardModelList(List<DeviceMaintenanceCardEntityExt> in) {
        if (in == null) return null;
        List<RegulatorDevice_MaintenanceCardModel> result = new ArrayList<>();
        for (DeviceMaintenanceCardEntityExt item : in) {
            result.add(ext2regulatorDevice_MaintenanceCardModel(item));
        }
        return result;
    }
    public RegulatorDevice_MaintenanceCardGetModel extList2regulatorDevice_MaintenanceCardGetModel(List<DeviceMaintenanceCardEntityExt> extList, Integer total, Integer changeCount, Map<String, Object> query) {
        List<RegulatorDevice_MaintenanceCardModel> modelList = extList2regulatorDevice_MaintenanceCardModelList(extList);
        if (modelList == null) {
            RegulatorDevice_MaintenanceCardGetModel result = new RegulatorDevice_MaintenanceCardGetModel();
            result.setTotal(total);
            result.setChangeCount(changeCount);
            return result;
        }

         String _show = HzhrTypeUtil.object2string(query.get("_show"));
         Boolean _show_info = query.get("_show_info") != null ? Boolean.parseBoolean(query.get("_show_info").toString()) : false;

        if (!_show_info) {
            for (RegulatorDevice_MaintenanceCardModel model : modelList) {
                model.setDeviceId(null);
                model.setYear(null);
            }
        }

        RegulatorDevice_MaintenanceCardGetModel result = new RegulatorDevice_MaintenanceCardGetModel();
        if ("one".equals(_show)) {
            if (modelList.size() > 0) {
                result.setModel(modelList.get(0));
            }
         }
        if ("list".equals(_show)) {
            result.setModelList(modelList);
        }
        result.setTotal(total);
        result.setChangeCount(changeCount);
        return result;
    }
    public RegulatorDevice_MaintenanceCardGetModel entity2regulatorDevice_MaintenanceCardGetModel(DeviceMaintenanceCardEntity entity, Integer total, Integer changeCount, Map<String, Object> query) {
        List<DeviceMaintenanceCardEntityExt> extList = new ArrayList<>();
        if (entity == null) return extList2regulatorDevice_MaintenanceCardGetModel(extList, total, changeCount, query);
        extList.add(HzhrJsonUtil.convertObjectType(entity, DeviceMaintenanceCardEntityExt.class));
        return extList2regulatorDevice_MaintenanceCardGetModel(extList, total, changeCount, query);
     }
    public DeviceMaintenanceCardEntity regulatorDevice_MaintenanceCardPostModel2entity(RegulatorDevice_MaintenanceCardPostModel in) {
        //未转换字段: createUserId createTime updateUserId isValid updateTime id state deviceId 
        if (in == null) return null;
        DeviceMaintenanceCardEntity result = new DeviceMaintenanceCardEntity();

        result.setYear(HzhrTypeUtil.object2string(in.getYear()));
        return result;
    }
    public DeviceMaintenanceCardEntity regulatorDevice_MaintenanceCardPostModel2entity(RegulatorDevice_MaintenanceCardPostModel in, DeviceMaintenanceCardEntity ori) {
        //未转换字段: createUserId createTime updateUserId isValid updateTime id state deviceId 
        if (in == null) return null;
        DeviceMaintenanceCardEntity result = ori;

        result.setYear(HzhrTypeUtil.object2string(in.getYear()));
        return result;
    }
    public List<DeviceMaintenanceCardEntity> regulatorDevice_MaintenanceCardPostModelList2entityList(List<RegulatorDevice_MaintenanceCardPostModel> in) {
        if (in == null) return null;
        List<DeviceMaintenanceCardEntity> result = new ArrayList<>();
        for (RegulatorDevice_MaintenanceCardPostModel item : in) {
            result.add(regulatorDevice_MaintenanceCardPostModel2entity(item));
        }
        return result;
    }
    public RegulatorDevice_MaintenanceCardPostModel entity2regulatorDevice_MaintenanceCardPostModel(DeviceMaintenanceCardEntity in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_MaintenanceCardPostModel result = new RegulatorDevice_MaintenanceCardPostModel();

        result.setYear(HzhrTypeUtil.string2integer(in.getYear()));
        return result;
    }
    public List<RegulatorDevice_MaintenanceCardPostModel> entityList2regulatorDevice_MaintenanceCardPostModelList(List<DeviceMaintenanceCardEntity> in) {
        if (in == null) return null;
        List<RegulatorDevice_MaintenanceCardPostModel> result = new ArrayList<>();
        for (DeviceMaintenanceCardEntity item : in) {
            result.add(entity2regulatorDevice_MaintenanceCardPostModel(item));
        }
        return result;
    }
    public RegulatorDevice_MaintenanceCardPostModel ext2regulatorDevice_MaintenanceCardPostModel(DeviceMaintenanceCardEntityExt in) {
        //未转换字段: 
        if (in == null) return null;
        RegulatorDevice_MaintenanceCardPostModel result = new RegulatorDevice_MaintenanceCardPostModel();

        result.setYear(HzhrTypeUtil.string2integer(in.getYear()));
        return result;
    }
    public List<RegulatorDevice_MaintenanceCardPostModel> extList2regulatorDevice_MaintenanceCardPostModelList(List<DeviceMaintenanceCardEntityExt> in) {
        if (in == null) return null;
        List<RegulatorDevice_MaintenanceCardPostModel> result = new ArrayList<>();
        for (DeviceMaintenanceCardEntityExt item : in) {
            result.add(ext2regulatorDevice_MaintenanceCardPostModel(item));
        }
        return result;
    }
    public DeviceMaintenanceCardCustomQueryModel regulatorDevice_MaintenanceCardService_query2queryModel(Map<String, Object> query) {
        DeviceMaintenanceCardCustomQueryModel queryModel = new DeviceMaintenanceCardCustomQueryModel();

        Integer _equal_id = HzhrTypeUtil.object2integer(query.get("_equal_id"));
        if (_equal_id != null) {
            queryModel.setEqual_id(_equal_id);
         }

        String _equal_year = HzhrTypeUtil.object2string(query.get("_equal_year"));
        if (_equal_year != null) {
            queryModel.setEqual_year(_equal_year);
         }

        Boolean _show_info = HzhrTypeUtil.object2boolean(query.get("_show_info"));
        if (_show_info != null && _show_info) {
            queryModel.setShow(true);
            queryModel.setShow(true);
        }

        Integer page = HzhrTypeUtil.object2integer(query.get("_page"));
        Integer count = HzhrTypeUtil.object2integer(query.get("_count"));
        queryModel.setPage(page, count);

        return queryModel;
    }

}

